/*
 * @Descripttion: 
 * @Author: cuidm
 * @Date: 2022-08-23 17:07:16
 * @LastEditors: cuidm
 * @LastEditTime: 2022-08-25 11:40:52
 */
import React, { useState, useEffect, useRef } from "react";
import { Form, Button, Input, Affix, Select, message, Space, Switch, Drawer, Row, Col, Modal } from "antd";
import { MinusCircleOutlined, PlusCircleOutlined } from '@ant-design/icons';
import { HcpTipModal } from "@/components";
import cmdbres from "@/data/cmdbres";
import hcpiam from "@/data/hcpiam";
import request, {requestIAM} from '@/utils/request';
import regexpUtil from "@/utils/regexpUtil";
import hcpUtils from "@/utils/hcpUtils";

const user = hcpUtils.getUser();
const HostPoolModule = ({ bizInfo, rowKeys, visible, setVisible, onFinish, cmModuleId}) => {
    const [loading, setLoading] = useState(false);

    const onSubmit = async (values) => {
        setLoading(true);
		let res = await request({
			...cmdbres.moveToResource,
			data: {
                bizId: bizInfo.bizId,
                serverIds: rowKeys,
                author: user.staffName,
                cmModuleId,
            }
		});
		setLoading(false);
		if (res && res.code == 200) {
			setVisible(false);
			message.success(`归还主机池成功！`);
			if (typeof onFinish == "function") onFinish(res);
		}
	};

    return (
        <HcpTipModal
            title="归还主机池"
            visible={visible}
            loading={loading}
            onFinish={onSubmit}
            onCancel={() => { setVisible(false) }}
            content={
                <>
                    <div className="main-content">
                        <span className="main-content-info"> 
                            确认将【{rowKeys?.length??0}】台空闲机转移到主机池？
                        </span>
                    </div>
                    <div className="sub-content gray">
                        请务必确认业务进程已停止或主机处于关机状态
                    </div>
                </>
            }
      />
    );
};

export default HostPoolModule;